package com.maochd.cloud.file.service.impl;

import cn.hutool.core.util.StrUtil;
import com.maochd.cloud.file.service.FileService;
import com.maochd.cloud.file.template.MinioTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@Service
public class FileServiceImpl implements FileService {

    @Resource
    private MinioTemplate minioTemplate;

    @Override
    public String upload(MultipartFile file, String filename) {
        if (StrUtil.isBlank(filename)) {
            return minioTemplate.putObject(file);
        }
        return minioTemplate.putObject(filename, file);
    }
}
